package com.ruoyi.web.controller.djb;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.djb.domain.DjbGate;
import com.ruoyi.djb.service.IDjbGateService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 门岗管理Controller
 * 
 * @author xxd
 * @date 2023-12-08
 */
@Controller
@RequestMapping("/djb/gate")
public class DjbGateController extends BaseController
{
    private String prefix = "djb/gate";

    @Autowired
    private IDjbGateService djbGateService;

    @RequiresPermissions("djb:gate:view")
    @GetMapping()
    public String gate()
    {
        return prefix + "/gate";
    }

    /**
     * 查询门岗管理列表
     */
    @RequiresPermissions("djb:gate:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(DjbGate djbGate)
    {
        startPage();
        List<DjbGate> list = djbGateService.selectDjbGateList(djbGate);
        return getDataTable(list);
    }

    /**
     * 导出门岗管理列表
     */
    @RequiresPermissions("djb:gate:export")
    @Log(title = "门岗管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(DjbGate djbGate)
    {
        List<DjbGate> list = djbGateService.selectDjbGateList(djbGate);
        ExcelUtil<DjbGate> util = new ExcelUtil<DjbGate>(DjbGate.class);
        return util.exportExcel(list, "门岗管理数据");
    }

    /**
     * 新增门岗管理
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存门岗管理
     */
    @RequiresPermissions("djb:gate:add")
    @Log(title = "门岗管理", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(DjbGate djbGate)
    {
        return toAjax(djbGateService.insertDjbGate(djbGate));
    }

    /**
     * 修改门岗管理
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Integer id, ModelMap mmap)
    {
        DjbGate djbGate = djbGateService.selectDjbGateById(id);
        mmap.put("djbGate", djbGate);
        return prefix + "/edit";
    }

    /**
     * 修改保存门岗管理
     */
    @RequiresPermissions("djb:gate:edit")
    @Log(title = "门岗管理", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(DjbGate djbGate)
    {
        return toAjax(djbGateService.updateDjbGate(djbGate));
    }

    /**
     * 删除门岗管理
     */
    @RequiresPermissions("djb:gate:remove")
    @Log(title = "门岗管理", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(djbGateService.deleteDjbGateByIds(ids));
    }
}
